﻿module Helper
open NUnit.Framework
open FsUnit
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
open Microsoft.FSharp.Linq.QuotationEvaluation

let shouldThrowException body exceptionType =
  <@ (fun () -> %body |> ignore) |> should throw %exceptionType @>.Eval()

/// Quotated body should throw exception of type T
let (|>!) body T =
  let e = Expr.Cast<System.Type>(Expr.Value(T))
  shouldThrowException body e